Skip to content

Conversation

@begedin
Copy link

@begedin begedin commented Jul 15, 2015

Description

This is a temporary PR where we can keep the discussion and have an overview of changes before the micro addon feature is ready to be merged into ember-cli/ember-cli.

Once the feature is ready, we can delete this PR and create a new one against ember-cli/ember-cli#master

ToDo

  • Clean up any potentially unnecessary stuff
  • Write tests
  • Write comments according to convention
  • Make sure the rest of the code is up to convention
  • Write a proper PR description, to be used in the actual PR

Final PR Description

This PR adds support to micro addons to ember-cli.

Premise

The idea here is to enable usage of a type of ember addon in which the file structure is greatly simplified. Micro-components, micro-helpers and micro-libraries are supported within the current PR.

Using coderly's CLI tool, we are able to generate a micro-addon of a specific type with a single command.

ember-micro:<addon-type>

However, in order to be able to use such an addon out of the box, we are forced to have a modified index.js which uses treeFor[Name] hooks in order to make the addon compatible with an Ember-CLI app. Basically, the logic which makes a micro-addon work is exposed.

Making Ember-CLI support this feature internally would hide away this logic and open up the road for additional CLI tools.

For example, with another command, we can almost instantly publish the micro-addon to github:

ember-micro:publish <addonName>

It is also possible to extract a component, helper or library out of an existing app into a micro-addon.

ember-micro:extract <addonType> <addonName> [-d|--destionation <destination>]

Finally, we have a command available which converts a micro-addon into a proper ember-addon

ember-micro:build <addonName>

The output is placed within /addon-name/dist.

The end result is a greatly simplified and sped up workflow. We can create and publish a micro-addon in under 20 seconds, or extract part of an ember application into an addon just as quickly.

Implementation

The micro-addon files are organized in a completely flat file structure with the following files

  • package.json for all addons. Needs to contain ember-addon as well as ember-micro-addon keywords
  • index.js for all addons, Looks pretty much the same as index.js in a regular ember addon
  • component.js, template.hbsandstyle.css` in the case of a micro-component
  • helper.js in the case on a micro-helper
  • library.js in the case of a micro-library

At build time, a micro-addon's files get renamed and moved so the micro-addon temporarily gets a proper addon structure. They are then available for import from the app/components, app/helpers or addon/lib namespace, depending on the type of addon.

@begedin
Copy link
Author

begedin commented Jul 16, 2015

@venkatd I'm not sure what else to add to the PR description. Do you have any ideas.

What slightly worries me is that I can imagine an argument along the lines of

Why does this need to be part of Ember-CLI? Why not just keep it as an addon?

The only answers I can think of are

  1. It's simpler to implement as part of Ember-CLI.
  2. It opens up a way to get more features into it.
  3. It hides away the currently exposed micro-addon logic.

Also, I'm still not sure how imports/exports of ES6 modules will work, or, for example, dependencies to other addons. My best argument there is that this is intended for very simple addons, so it should not work out of the box.

@venkatd
Copy link

venkatd commented Jul 20, 2015

@begedin I would also explain the motivation further: To improve the Ember addon ecosystem by speeding up the process and learning curve for creating addons.

It should be possible to create and share an addon within 60 seconds.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this should be encapsulated in the lookup method itself.

@begedin begedin closed this Jul 5, 2023
@venkatd
Copy link

venkatd commented Jul 7, 2023

But @begedin we're still waiting to finish this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants